<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
    <script type="text/javascript" src="../js/ajax.js"></script>
    <script>

        var prov;
        var city;

        function refresh() {
            prov = document.getElementById("prov");
            city = document.getElementById("city");
            var p = prov.value;
            if(p==""){
                city.length=0;
                city.options.add(new Option("请选择城市"));//options 开始没加s 导致出错
            }else {
                var url=";";//servlet 地址
                var params = "proc="+prov.value;
                sendRequest(url,params,'POST',show);
            }
        }

        function show() {
            if (xmlHttpRequest.readyState == 4){
                if(xmlHttpRequest.status == 200){
                    var citylist = xmlHttpRequest.responseText.split(",");
                    var citynum=citylist.length;
                    city.length=0;
                    for(var i=0;i<citynum;i++){
                        city.options.add(new Option(citylist[i]));
                    }
                }
            }
        }
    </script>
</head>
<body>
    <form action="">
        <select id="prov" name="prov" onchange="refresh()">
            <option value="">--请选择省份</option>
            <option value="山东">山东</option>
            <option value="江苏">江苏</option>
            <option value="广东">广东</option>
        </select>

        <select name="city" id="city">
            <option value="">--请选择城市</option>
        </select>
    </form>
</body>
</html>